package edu.scau.payment.service;

import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayConfig;
import com.fasterxml.jackson.core.JsonProcessingException;
import edu.scau.payment.config.AliPayConfig;
import edu.scau.payment.domain.Payment;
import edu.scau.payment.vo.PaymentVo;

import java.util.List;
import java.util.Map;

public interface PaymentService {

    Payment createPayment(String orderId,double amount);
    AlipayConfig getAlipayConfig();
    String createAndPay(Payment successPayment,Payment pendingPayment) throws AlipayApiException;
    int asyncNotify();

    boolean queryManualByOrderID(String orderId) throws AlipayApiException, JsonProcessingException;
    Payment updatePaymentMsgAfterPay(String orderId, Map resultMap) throws AlipayApiException, JsonProcessingException;

    /**
     * 查找所有
     * @return 列表
     */
    List<PaymentVo> listAll();

    /**
     * 根据id查找一条数据
     * @param paymentId id
     * @return Payment
     */
    PaymentVo findPaymentByPaymentId(String paymentId);

//    /**
//     * 分页查找
//     * @param paymentVo 对象
//     * @return 列表
//     */
//    List<PaymentVo> listByPage(PaymentVo paymentVo);



    /**
     * 根据id更新一条数据
     * @param payment 对象
     * @return 影响行数
     */
    int updatePayment(Payment payment);

    /**
     * 根据id删除一条数据
     * @param paymentId id
     * @return 影响行数
     */
    int deletePaymentById(String paymentId);

    /**
     * 插入一条数据
     * @param payment 对象
     * @return 影响行数
     */
    int insertPayment(Payment payment);
    boolean isExisted(String paymentId);

    public Map queryByOrderID(String orderId) throws AlipayApiException, JsonProcessingException;

    /**
     *
     * 商品退货退款
     * @param outTradeId
     * @param refundAmount
     * @param desc
     * @return
     */
    Map refund(String outTradeId, double refundAmount, String desc,String refundId) throws AlipayApiException, JsonProcessingException;

    Map queryRefundStatus(String refundId,String orderId) throws AlipayApiException, JsonProcessingException;
}
